package cuit.util;

import java.sql.Connection;
import java.sql.DriverManager;

public class Database {
	private static Connection connection = null;

	public static Connection getConnection() {
        if (connection != null)
            return connection;
        else {
    		try {
    			Class.forName("com.mysql.jdbc.Driver");
    			connection = DriverManager.getConnection(
    					"jdbc:mysql://localhost:3306/cuit?useUnicode=true&characterEncoding=UTF8", "root", "951223");
    			return connection;
    		} catch (Exception ex) {
    			System.out.println("Database.getConnection() Error -->"
    					+ ex.getMessage());
    			return null;
    		}        	
        }
	}

	public static void close() {
		try {
	        if (connection != null)
	           connection.close();
		} catch (Exception ex) {
		}
	}
}
